﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Ccit.OA.Scheduler
{
    public partial class scheduler_Param_set : Ccit.Utils.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitPage();
            }
        }

        private void InitPage()
        {
            for (int i = 0; i <=24;i++ )
            {
                ddlBegHour.Items.Add(i.ToString());
                ddlEndHour.Items.Add(i.ToString());
            }
            DataBinde();
        }
        private void DataBinde()
        {
            SchedulerBLL Bll = new SchedulerBLL();
            MsSchParam msParam = Bll.GetMsSchParamMes();
            if(msParam!=null)
            {
                string[] BegTime = msParam.ShowBeginTime.Split(':');
                string[] endTime = msParam.ShowEndTime.Split(':');
                radioList.SelectedValue = msParam.ShowDefaultStyle;
                ddlBegHour.SelectedValue = BegTime[0];
                ddlBegSecond.SelectedValue = BegTime[1];
                ddlEndHour.SelectedValue = endTime[0];
                ddlEndSecond.SelectedValue = endTime[1];
                radioCalendar.SelectedValue = msParam.ShowCalendar;
            }
        }
        #region Ajax Methods
        [global::System.Web.Services.WebMethod]
        public static string DoSaveMes(string strJson)
        {
            SchedulerBLL Bll = new SchedulerBLL();
            MsSchParam ms = (MsSchParam)JavaScriptConvert.DeserializeObject(strJson, typeof(MsSchParam));
            List<string> lstResult = Bll.DoSaveParamMes(ms);
            var newObj = new { result = lstResult[0], message = lstResult[1]};
            string serExpr = JavaScriptConvert.SerializeObject(newObj);
            Bll = null;
            newObj = null;
            return serExpr;
        }
        #endregion
    }
}
